class Solution:
    def sumNums(self, n: int) -> int:
        """python中and返回最后一个值，到n=0时不再计算递归"""
        return n and (n + self.sumNums(n-1))

if __name__ == '__main__':
    c = Solution()
    print(c.sumNums(4))